package com.yidu.BusinessParament.mapper;

import com.yidu.BusinessParament.entity.DealSeat;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @交易席位 Mapper类
 * @version 1.0
 * @auther 林肯
 * @date 2022/12/12 -9:36
 */
@Mapper
public interface DealSeatMapper {
    /**
     * page 页码
     * limit 每页显示的条数
     * 查询数据
     * @param map
     * @return
     */
    @Select("select d.*,b.`brokerId` from dealSeat d inner join dealSeat b on d.`brokerId`=b.`brokerId`  where 1=1 ${sqlWhere} limit #{page},#{limit}")
    List<DealSeat> selectDealSeat(Map map);

    /**
     * 分页查行数 模糊查询后的行数 根据条件
     * @param map
     * @return
     */
    @Select("select count(*) from dealSeat d inner join dealSeat b on d.`brokerId`=b.`brokerId` where 1=1 ${sqlWhere}")
    int selectCount(Map map);

    /**
     * 添加数据
     * @param dealSeat 交易席位
     * @return
     */
    @Insert("insert into dealSeat values(#{seatId},#{brokerId},#{seatType},#{seatName},#{seatPlace},#{commission},#{remark})")
    int insertDealSeat(DealSeat dealSeat);

    /**
     * 删除数据
     * @param seatId 交易席位
     * @return
     */
    int deleteDealSeat(List<String> seatId);

    @Update("update dealSeat set brokerId=#{brokerId},seatType=#{seatType},seatName=#{seatName},seatPlace=#{seatPlace},commission=#{commission},remark=#{remark} where seatId=#{seatId}")
    int updateDealSeat(DealSeat dealSeat);

    /**
     * 获取最大ID的方法
     * @return
     */
    @Select("select seatId from dealSeat order by seatId desc limit 1")
    public String selectMaxId();
}
